import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Login from "../views/Login.vue";
import Test from "../test/test.vue";
import Layout from "../components/Layout.vue";
import Error404 from "../pages/error/404.vue";
import Error403 from "../pages/error/403.vue";
import Error500 from "../pages/error/500.vue";
import Info from "../pages/notifications/Info.vue";
import AccountCenter from "../pages/account/AccountCenter.vue";

const staticRouterList: RouteRecordRaw[] = [
  {
    path: "/login",
    component: Login,
  },
  // 测试使用
  {
    path: "/testDemo",
    component: Test,
  },
];

const errorRouteList: RouteRecordRaw[] = [
  {
    path: "/error",
    component: Layout,
    redirect: "/error/404",
    children: [
      {
        path: "/error/404",
        component: Error404,
      },
      {
        path: "/error/403",
        component: Error403,
      },
      {
        path: "/error/500",
        component: Error500,
      },
    ],
  },
];

const funcRouteList: RouteRecordRaw[] = [
  {
    path: "/notifications",
    component: Layout,
    redirect: "/notifications/info",
    children: [
      {
        path: "/notifications/info",
        component: Info,
        meta: {
          isDisplayPage: true,
        },
      },
    ],
  },
  {
    path: "/account",
    component: Layout,
    redirect: "/account/center",
    children: [
      {
        path: "/account/center",
        component: AccountCenter,
        meta: {
          isDisplayPage: true,
        },
      },
    ],
  },
];

const defaultRouterList: RouteRecordRaw[] = [
  ...staticRouterList,
  ...errorRouteList,
  ...funcRouteList,
];
//
const routerHistory = createWebHistory();
const router = createRouter({
  history: routerHistory,
  routes: defaultRouterList,
});

export default router;
